package printNumAndLetter

import "fmt"

var chanInt = make(chan bool, 1)
var chanNum = make(chan bool)
var startChan = make(chan bool, 1)

// 通过channel 控制主程序的结束
func printNum() {
	for i := 1; i < 26; i += 2 {
		<-chanInt
		fmt.Print(i)
		fmt.Print(i + 1)

		chanNum <- true
	}
}

func printLetter() {
	for i := 'A'; i <= 'Z'; i += 2 {
		<-chanNum
		fmt.Print(string(i))
		fmt.Print(string(i + 1))

		chanInt <- true
	}
	startChan <- true
}

func main() {
	chanInt <- true

	go printNum()
	go printLetter()

	<-startChan
}
